﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Expect.Core.IO;
using Expect.Core.Reports;

namespace Expect.Core.Test.IO
{
    [TestClass]
    public class ReportMetadataTests
    {
        [TestMethod]
        public void ReportMetadata_parsing()
        {
            var content = Helper.LoadFromRessourceFile("reportmetadata.txt");
            var data = new DummyReportData();
            TextReportMetadataReader reader = new TextReportMetadataReader(data);
            reader.ReadReportMetadata(content);

            Assert.AreEqual(5, data.Count);

            Assert.AreEqual("a sample file", data[0].Name);
            Assert.AreEqual("a folder", data[1].Name);
            Assert.AreEqual(ReportItemKind.Folder, data[1].Kind);
            Assert.AreEqual("another file", data[2].Name);
            Assert.AreEqual("folder 1", data[3].Name);
            Assert.AreEqual("folder 2", data[4].Name);
        }
    }

    internal class DummyReportData : ReportMetadataBase
    {
        public bool Initialized { get; private set; }

        public override void Initialize()
        {
            Initialized = true;
        }
    }
}
